package com.forg.mvc.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.forg.mvc.core.annotation.InterceptPath;
import com.forg.mvc.core.annotation.Interceptor;
import com.forg.mvc.core.common.RequestUtil;
import com.forg.mvc.core.excception.InterceptorInterruptException;

@Interceptor
public class HelloInterceptor {
    
    private static final Logger logger = LoggerFactory.getLogger(HelloInterceptor.class);
    
    @InterceptPath("/hello1.do")
    public void beforeSayHello1_1(){
        
        RequestUtil.addParam("lala", "xxx");
        logger.debug("HelloInterceptor.hello1_1.do");
    }
    
    @InterceptPath("/hello1.do")
    public void beforeSayHello1_2(){
        
        logger.debug("HelloInterceptor.hello1_2.do");
    }
    
    @InterceptPath(value="/hello1.do",priority=-100)
    public void beforeSayHello1_3(){
        
        throw new InterceptorInterruptException("end it!!!");
    }
    
    @InterceptPath(value="/hello4.do",priority=2)
    public boolean beforeSayHello4_1(){
        
        logger.debug("HelloInterceptor.beforeSayHello4_1 priority=2");
        return true;
    }
    
    @InterceptPath(value="/hello4.do",priority=3)
    public boolean beforeSayHello4_2(){
        
        RequestUtil.addParam("lala", "xxx");
        logger.debug("HelloInterceptor.beforeSayHello4_2 priority=3");
        return true;
    }
    
    @InterceptPath(value="/hello4.do",priority=4)
    public boolean beforeSayHello4_4(){
        
        RequestUtil.addParam("lala", "xxx");
        logger.debug("HelloInterceptor.beforeSayHello4_4 priority=4");
        
        return true;
    }

}
